package com.rimi.manager.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.rimi.entity.PageResult;
import com.rimi.entity.Result;
import com.rimi.pojo.TbBrand;
import com.rimi.sellergoods.service.BrandService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
//Controller+responseBody
@RestController
@RequestMapping("/brand")
public class BrandController {

	@Reference
	private BrandService brandService;

	@RequestMapping("/findAll")
	public List<TbBrand> findAll(){
		return brandService.findAll();
	}

	@RequestMapping("/findPage")
	public PageResult findPage(int page,int size){
//简单int类型,通过get ?问号形式传递
return brandService.findPage(page,size);
	}

	//@RequestBody通过前端post方式传入进来数据
	@RequestMapping("/add")
	public Result add(@RequestBody TbBrand brand){
try {
	brandService.add(brand);
return new Result(true,"新增成功");

}catch (Exception e
){
	return new Result(false,"新增失败	");

}
//		return
	}

}
